﻿package {
    import flash.display.*;
    import flash.media.Camera;
    import flash.media.Video;

    public class WebCam extends Sprite {
        private var video:Video;
		private var holder_mc:MovieClip;
        private var bIsAdded:Boolean;
        private var mainRef:Sprite;
        
        public function WebCam(_mainref:Sprite,_w:Number, _h:Number) {
        	mainRef = _mainref;
            var camera:Camera = Camera.getCamera();
			holder_mc = new MovieClip();
			this.addChild(holder_mc);
			bIsAdded = false;
            
            if (camera != null) {
                video = new Video(_w, _h);
                video.attachCamera(camera);
              	holder_mc.addChild(video);
              	bIsAdded = true;
				trace( "Camera added" );
            } else {
            	bIsAdded = false;
                trace("You need a camera.");
            }
        }	
        public function get isAdded():Boolean {
        	return bIsAdded;
        }	
    }
}